<?php

/**
 * 核算类型仓库
 * @author wangwx 2015-5-15
 */
namespace common\repositories\myhtsq;
use common\repositories\BaseRepository;
use common\support\StringHelper;
use common\entities\myhtsq\InvoiceEntity;
use common\entities\myhtsq\BussAccountTypesEntity;
class BussAccountTypesRepository extends BaseRepository{

	/**
	 * 构造方法
	 * @param unknown $config (optional)
	 */
	public function __construct($config = [])
	{
		parent::__construct($config);
	}
	
	
	/**
	 * 获取所有核算类型
	 * @return array
	 */
	public static function getAllBussAccountTypes() {
		return BussAccountTypesEntity::find()->select('type_id,type_name,finance_type_name')->all();
	}

    /**
     * 根据类别名称获取ID
     *
     * @param  $name  类别名称
     * @return string
     */
    public static function getRevenueTypeIdByName($name){
        $map['type_name'] = $name;

        //坏味道修复
        return BussAccountTypesEntity::find()->where($map)->select('type_id')->scalar();

    }

    /**
     * 根据业务收入项和财务收入项获取类别ID
     *
     * @param $typeName
     * @param $financeName
     * @return bool|string
     */
    public static function getBussTypeIdByName($typeName, $financeName) {
        $map['type_name'] = $typeName;
        $map['finance_type_name'] = $financeName;

        return BussAccountTypesEntity::find()->where($map)->select('type_id')->scalar();
    }
	
	
}